"""_summary_
主进程的全局变量，在子线程中共享，未锁定，存在问题
"""

import threading
import time

num = 0


def work1():
    global num
    for i in range(1000000):
        num += 1
    print("子线程1运行，num:", num)


def work2():
    global num
    for i in range(1000000):
        num += 1
    print("子线程2运行，num:", num)


if __name__ == "__main__":
    print("父进程开始运行")
    t1 = threading.Thread(target=work1)
    t2 = threading.Thread(target=work2)
    t1.start()
    t2.start()
    t1.join()
    t2.join()
    print("父进程运行结束，num:", num)
